#ifndef __DANIEL_MYAES_H__
#define __DANIEL_MYAES_H__

#include <openssl/aes.h>
#include <string>
#include <memory>

namespace daniel
{
    class MyAes
    {
    public:
        using ptr=std::shared_ptr<MyAes>;
        MyAes(){};
        MyAes(const std::string& key,const std::string& ivec)
        {
            m_key=key.substr(0,16);
            m_ivec=ivec.substr(0,16);
        }
        ~MyAes()
        {}
        void setKey(const std::string& key){m_key=key.substr(0,16);}
        std::string getKey() const {return m_key;}
        void setIvec(const std::string& ivec){m_ivec=ivec.substr(0,16);}
        std::string getIvec() const {return m_ivec;}
        //浅封装
        void aesCbcEncrypt(uint8_t* in, uint8_t* out, uint32_t len);
        void aesCbcDecrypt(uint8_t* in, uint8_t* out, uint32_t len);
    private:
        //加密密钥和初始化向量
        std::string m_key;
        std::string m_ivec;
    };
}

#endif